<?php
/*
Template Name: Homepage
*/
?>

<?php get_header(); ?>

<div class="homepage-top-images">

<?php
//get the data to an array
$data = get_option('demo_options');
//access each field by its id
$data['options'];

$homepage_image_large = $data['homepage_image_large'];
$homepage_image_large_url = $homepage_image_large['src'];
$homepage_image_large_id = $homepage_image_large['id'];
echo "<div class='homepage_image_large'>";
echo "<img src='$homepage_image_large_url'>";
global $wpdb;
$image_caption = $wpdb->get_var("SELECT post_excerpt FROM wp_posts WHERE ID = '$homepage_image_large_id' ");
echo "<div class='homepage_image_large_text'>";
echo $image_caption;
echo "</div>";
echo "</div>";
//echo $homepage_image_large_id;

$homepage_image_small_top = $data['homepage_image_small_top'];
$homepage_image_small_top_url = $homepage_image_small_top['src'];
$homepage_image_small_top_id = $homepage_image_small_top['id'];
echo "<div class='homepage_image_small'>";
echo "<img src='$homepage_image_small_top_url'>";
global $wpdb;
$image_caption = $wpdb->get_var("SELECT post_excerpt FROM wp_posts WHERE ID = '$homepage_image_small_top_id' ");
echo "<div class='homepage_image_small_text'>";
echo $image_caption;
echo "</div>";
echo "</div>";
//echo $homepage_image_small_top_id;

$homepage_image_small_bottom = $data['homepage_image_small_bottom'];
$homepage_image_small_bottom_url = $homepage_image_small_bottom['src'];
$homepage_image_small_bottom_id = $homepage_image_small_bottom['id'];
echo "<div class='homepage_image_small_bottom'>";
echo "<img src='$homepage_image_small_bottom_url'>";
global $wpdb;
$image_caption = $wpdb->get_var("SELECT post_excerpt FROM wp_posts WHERE ID = '$homepage_image_small_bottom_id' ");
echo "<div class='homepage_image_small_text'>";
echo $image_caption;
echo "</div>";
echo "</div>";
//echo $homepage_image_small_bottom_id;

?>

</div>

<div class="clear"></div>

<div class="cost-calculator">
	<div class="cost-calculator-left">
		<h1>Cost Calculator</h1>
		<p>
			<?php 
				$calculator_text = $data['calculator_text'];
				echo $calculator_text
			?>
		</p>
	</div>
	<div class="cost-calculator-right">
		<a href="<?php bloginfo('url'); ?>/">
			<div class="cost-calculator-right-more">
				Learn More
			</div>
		</a>
	</div>
</div>

<div class="services">

	<h1>Services</h1>

<div class="clear"></div>

<div class="als-container" id="demo2">
<div class="als-viewport">
<ul class="als-wrapper">

	<?php
  query_posts( array( 'post_type' => 'services', 'showposts' => 10 ) );
  if ( have_posts() ) : while ( have_posts() ) : the_post();
?>

<li class="als-item">

  <h2><?php the_title(); ?></h2>

  <?php print_excerpt(150); ?> 

  <div class="readmore"><a href="<?php the_permalink(); ?>">Read More</a></div>


</li>

<?php endwhile; endif; wp_reset_query(); ?>
</ul>
</div>
<span class="als-prev"></span>
<span class="als-next"></span>
</div>

<div class="clear"></div>

</div>
</div>
<div class="servicesfull">
<div id="wrapper">


<div class="key-sectors">
	<h1>Key Sectors</h1>
<?php
  query_posts( array( 'post_type' => 'key-sectors', 'showposts' => 10 ) );
  if ( have_posts() ) : while ( have_posts() ) : the_post(); $count++;
?>

<div class="eachsector <?php if(0 == $count%3) echo "last" ?>">

<div class="sector_image">
	<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
</div>

<a href="<?php the_permalink(); ?>">
	<div class="icon_image">
		<img src="<?php the_field('icon'); ?>" alt="" />
	</div>
	<div class="sector_title">
		<h2><?php the_title(); ?></h2>
	</div>
</a>

<div class="sector_home_text">
	<?php print_excerpt(200); ?>
</div>

</div>
<?php endwhile; endif; wp_reset_query(); ?>
</div>
</div>



<?php get_footer(); ?>